package com.xbongbong.saas.model;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.saas.domain.entity.WorkOrderFlowNodeEntity;
import com.xbongbong.saas.domain.entity.ext.WorkOrderNodeAvgTimeEntityExt;

import java.util.List;
import java.util.Map;
/**
 *
 * @author 魏荣杰
 * @date 2019/3/11 19:38
 * @since v1.0
 * @version v1.0
 */
public interface WorkOrderFlowNodeModel extends IModel<WorkOrderFlowNodeEntity> {
    @Override
    Integer insert(WorkOrderFlowNodeEntity entity) throws XbbException;

    @Override
    Integer update(WorkOrderFlowNodeEntity entity) throws XbbException;

    @Override
    List<WorkOrderFlowNodeEntity> findEntitys(Map<String, Object> param);

    @Override
    Integer getEntitysCount(Map<String, Object> param);

    Integer save(WorkOrderFlowNodeEntity entity) throws XbbException;
    /**
     * Description: 根据查询参数获取用户id
     * @return java.util.List<java.lang.String>
     * @author 魏荣杰
     * @date 2019/4/15 11:00
     * @since v1.0
     */
    List<String> getUserIdList(Map<String, Object> param);

    /**
     * Description: 根据参数查询获取节点信息
     * @param  workOrderId，isNow，corpId
     * @return WorkOrderFlowNodeEntity
     * @author 刘阳
     * @date 2019/4/18 10:49 AM
     * @since v1.0
     */
    List<WorkOrderFlowNodeEntity> getNode(Long workOrderId, Integer isNow, String corpId);

    WorkOrderFlowNodeEntity getByKey(Long sourceId, String corpid);

    /**
     * 获取上一节点
     * @param params
     * @return
     */
    WorkOrderFlowNodeEntity getPrevNode(Map<String,Object> params);
    /**
     * 获取平均耗时
     *
     * @param param 入参
     * @return com.xbongbong.saas.domain.entity.ext.WorkOrderNodeAvgTimeEntityExt
     * @author 徐俊杰
     * @date 2019/4/18 17:13
     * @since v1.0
     */
    List<WorkOrderNodeAvgTimeEntityExt> getStageAverageTime(Map<String, Object> param);

    WorkOrderFlowNodeEntity getLastNode(Long workOrderId, Long stageId, String corpid);

    /**
     * 获取负责的工单id
     * @param corpid
     * @param userIdIn
     * @return
     */
    List<Long> getWorkOrderIdResponsibleByUserIdIn(String corpid, List<String> userIdIn);

    /**
     * 超时或未超时
     * @param corpid
     * @param userIdIn
     * @param isOut
     * @return
     */
    List<Long> getTimeOutNode(String corpid, List<String> userIdIn,Boolean isOut);

    List<Long> workOrderIdList(Map<String,Object> param);

    /**
     * Description:批量删除
     * @param workOrderIdIn
     * @param corpid
     * @return java.lang.Integer
     * @author 魏荣杰
     * @date 2019/5/9 11:20
     * @since v1.0
     */
    Integer deleteByWorkOrderIdIn(List<Long> workOrderIdIn, String corpid);

    /**
     * Description: 根据userId和workOrderID查询阶段状态
     * @param corpid
     * @param workOrderIdIn
     * @param userId
     * @return java.util.List<WorkOrderFlowNodeEntity>
     * @author 刘阳
     * @date 2019/6/5 10:05 AM
     * @since v1.0
     */
    List<WorkOrderFlowNodeEntity> getWorkOrderFlowStatus(String corpid, List<Long> workOrderIdIn,  String userId);

    /**
     * Description: 根据userIdIn和workOrderID查询阶段状态
     * @param corpid
     * @param workOrderIdIn
     * @param userIdIn
     * @return java.util.List<WorkOrderFlowNodeEntity>
     * @author 刘阳
     * @date 2019/8/2 8:14 PM
     * @since v1.0
     */
    List<WorkOrderFlowNodeEntity> getWorkOrderFlowStatus1(String corpid, List<Long> workOrderIdIn, List<String> userIdIn);

    WorkOrderFlowNodeEntity getLastNodeByStageList(Long workOrderId, List<Long> preStageList, String corpid);
}
